package com.example.demo.runner;

import com.example.demo.properties.BaseInfoProps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component // 次注解不能缺少
@Order(value = 2)
public class BaseInfoRunner implements ApplicationRunner {

    @Autowired
    private BaseInfoProps props;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        String name = props.getName();

        String sex = props.getSex();

        System.out.println("自定义base.info配置信息:" + "name:" + name + ",sex:" + sex + ",salary:" + props.getSalary());
    }
}
